<script>
import { setStorage, getStorage } from './utils/auth'
export default {
  onLaunch() {
    // app启动加载时，从本地中获取用户信息
    try {
      const userInfo = uni.getStorageSync('userInfo')
      // 有的话，提交到Vuex存储，防止刷新数据丢失
      userInfo && this.$store.commit('user/initUserInfo', userInfo)
    } catch (e) {
      console.log(e)
    }

    // 存储购物车数据到本地及vuex
    getStorage('cartList')
      .then(value => {
        console.log(value, 'app')
        this.$store.commit('cart/initCartList', value)
      })
      .catch(err => {
        setStorage('cartList', [])
      })
  },
}
</script>

<style lang="scss">
/* @import 'uview-ui/index.scss'; */
* {
  box-sizing: border-box;
}
html,
page {
  width: 100vw;
  height: 100vh;
}
</style>
